package com.whnk.attendance.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.whnk.attendance.domain.MonthIncomeStatis;
import com.whnk.attendance.mapper.MonthIncomeStatisMapper;
import com.whnk.attendance.vo.MonthIncomeStatisJsonVo;
import com.whnk.attendance.vo.MonthIncomeStatisVo;
import com.whnk.attendance.vo.MonthWorkIncomeJsonVo;
import com.whnk.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.whnk.common.log.annotation.Log;
import com.whnk.common.log.enums.BusinessType;
import com.whnk.common.security.annotation.PreAuthorize;
import com.whnk.attendance.service.IMonthIncomeStatisService;
import com.whnk.common.core.web.controller.BaseController;
import com.whnk.common.core.utils.poi.ExcelUtil;
import com.whnk.common.core.web.page.TableDataInfo;

/**
 * 每月统计收入Controller
 *
 * @author whnk
 * @date 2021-11-17
 */
@Api(tags = "每月统计收入Controller")
@RestController
@RequestMapping("/monthIncomeStatis")
public class MonthIncomeStatisController extends BaseController
{
    @Autowired
    private IMonthIncomeStatisService monthIncomeStatisService;

    /**
     * 查询每月收入统计
     */
    @ApiOperation(value = "查询每月收入统计", notes = "查询每月收入统计")
    @PreAuthorize(hasPermi = "attendance:statis:list")
    @GetMapping("/list")
    public AjaxResult list(@ApiParam(value = "每月收入统计信息",required = true) String month){
        return AjaxResult.success(monthIncomeStatisService.selectMonthIncomeStatisVoList(month));
    }

    /**
     * 导出每月收入统计
     */
    @ApiOperation(value = "导出每月收入统计")
  //  @PreAuthorize(hasPermi = "attendance:statis:export")
    @Log(title = "导出每月收入统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, String month) throws IOException
    {
        MonthIncomeStatisJsonVo monthIncomeStatisJsonVo = monthIncomeStatisService.selectMonthIncomeStatisVoList(month);
        monthIncomeStatisService.exportExcel(response, monthIncomeStatisJsonVo);
    }

    /**
     * 批处理每月收入统计
     */
    @PostMapping("/insert")
    @ApiOperation(value = "批处理每月收入统计", notes = "批处理每月收入统计")
    public void batchComputer(@Validated @RequestBody String month){
        monthIncomeStatisService.batchComputer(month);
    }

}
